package com.example.app.Entity;
import static androidx.room.ForeignKey.CASCADE;
import androidx.constraintlayout.widget.Group;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;
@Entity(
    tableName = "messages",
    foreignKeys = {
        @ForeignKey(
            entity = User.class,
            parentColumns = "id",
            childColumns = "sender_id",
            onDelete = CASCADE
        ),
        @ForeignKey(
            entity = User.class,
            parentColumns = "id",
            childColumns = "receiver_id",
            onDelete = CASCADE
        ),
        @ForeignKey(
            entity = Group.class,
            parentColumns = "id",
            childColumns = "group_id",
            onDelete = CASCADE
        )
    }
)
public class Message {
    @PrimaryKey(autoGenerate = true)
    private Long id;
    @ColumnInfo(name = "sender_id")
    private Long senderId;
    @ColumnInfo(name = "receiver_id")
    private Long receiverId;
    @ColumnInfo(name = "group_id")
    private Long groupId;
    private String content;
    @ColumnInfo(name = "type")
    private MessageType type;
    @ColumnInfo(name = "timestamp")
    private Long timestamp;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getSenderId() {
        return senderId;
    }

    public void setSenderId(Long senderId) {
        this.senderId = senderId;
    }

    public Long getReceiverId() {
        return receiverId;
    }

    public void setReceiverId(Long receiverId) {
        this.receiverId = receiverId;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public MessageType getType() {
        return type;
    }

    public void setType(MessageType type) {
        this.type = type;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }
}